package com.zat.mes.andrmes.dofun.work.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zat.mes.andrmes.R
import com.zat.mes.andrmes.data.EmpBeanItem
import com.zat.mes.andrmes.utils.SpannableStrUtil

/**
 * @author zy
 * @date :2020-02-25 16:16
 * @description:员工做工日计划 日记录 adapter
 */
class DayProduceEmpListAdapter(layoutResId: Int,work:Boolean) :
    BaseQuickAdapter<EmpBeanItem, BaseViewHolder>(layoutResId) {
    private var work = work

    override fun convert(helper: BaseViewHolder, item: EmpBeanItem) {

        helper.setText(R.id.tvNameEmpListItem, item?.empname)
        if (item?.quantity != 0) {
            var str = context.getString(R.string.text_today_plan_amount)
            if(work){
                str = context.getString(R.string.text_today_record_amount)
            }
            var quantity =
                item?.quantity.toString() + "\n" + str
            helper.setText(
                R.id.tvNumEmpListItem,
                SpannableStrUtil.getColorSpannable(
                    quantity,
                    quantity.length - 5,
                    quantity.length,
                    ContextCompat.getColor(context, R.color.color_text_333)
                )
            )
        } else {
            helper.setText(R.id.tvNumEmpListItem, "")
        }

    }
}